package br.com.mmm.javacenter.framework.reflection.injectors;

import java.util.Calendar;
import java.util.Date;

import br.com.mmm.javacenter.framework.annotations.InjectorComponent;
import br.com.mmm.javacenter.framework.formatters.DateFormat;
import br.com.mmm.javacenter.framework.reflection.ReflectionFacade;


@InjectorComponent({
	Date.class,
	Calendar.class
})
public class DateInjector implements Injector{
	public void inject(ReflectionFacade rf,String field, Object value) {
		if(value!=null){
			try{
				Date parse = DateFormat.simpleDate.parse(value.toString());
				rf.set(field, parse);
			}catch(Exception e){
				rf.set(field,null);
			}
		}
	}

}
